package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.AssentFileInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.frame.security.bean.dto.UserDto;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IAssentFileInfoConsumeService;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/AssentFileInfo" })
@Api("AssentFileInfoController")
@CrossOrigin
public class AssentFileInfoController {

	@Autowired
	private IAssentFileInfoConsumeService assentFileInfoConsumeService;
	
	@GetMapping(value = { "/getAssentFileInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
    @ApiOperation("查询附件List")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "fileId", value = "附件编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devCategoryCode", value = "设备类别编号", paramType = "query", dataType = "String")})
	public ResultPojo getAssentFileInfoList(
			@RequestParam(defaultValue = "",value="fileId",required=false) String fileId,
			@RequestParam(defaultValue = "",value="devId",required=false) String devId,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="devCategoryCode",required=false) String devCategoryCode,
			HttpServletRequest request) {
		ResultPojo resultPojo = assentFileInfoConsumeService.getAssentFileInfoList(fileId, devId, devTypeCode, devCategoryCode);
		return resultPojo;
	}
	
	@GetMapping(value = { "/deleteAssentFileInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=AssentFileInfoDto.class, code = 0, message = "")
    @ApiOperation("根据附件编号删除附件")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "fileId", value = "附件编号", paramType = "query", dataType = "String")})
	public ResultPojo deleteAssentFileInfo(
			@RequestParam(defaultValue = "",value="fileId",required=false) String fileId,
			HttpServletRequest request) {
		return assentFileInfoConsumeService.deleteAssentFileInfo(fileId, 
                ((UserDto) request.getAttribute("currentUser")).getPersonName());
	}
	
	
	@GetMapping(value = { "/insertAssentFileInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=AssentFileInfoDto.class, code = 0, message = "")
    @ApiOperation("附件信息添加")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "list", value = "附件编号", paramType = "query", dataType = "String")})
	public ResultPojo insertAssentFileInfo(
			@RequestParam(defaultValue = "",value="list",required=false) String list,
			HttpServletRequest request) {
		return assentFileInfoConsumeService.insertAssentFileInfo(list, ((UserDto) request.getAttribute("currentUser")).getPersonName());
	}
}
